package com.hctg.forced2sleep.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hctg.forced2sleep.R;

import org.jetbrains.annotations.NotNull;

/**
 * description: 描述
 * company    :
 *
 * @author : ldf
 * date       : 2024/12/1 on 14
 * @version 1.0
 */
public class EditMinuteActivityAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    public EditMinuteActivityAdapter() {
        super(R.layout.item_time_list);
        addChildClickViewIds(R.id.iv_close);
        setOnItemChildClickListener((adapter, view, position) -> {
            removeAt(position);
        });
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, String item) {
        boolean isLastItem = holder.getAbsoluteAdapterPosition() == getData().size() - 1;
        holder.setText(R.id.tv_num, item)
                .setVisible(R.id.iv_vip, isLastItem)
                .setVisible(R.id.iv_close, !isLastItem);
    }
}
